﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="card_master.aspx.cs" Inherits="backmanage_cardsystem_card_master" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>新手卡管理</title>
    <script type="text/javascript" src="../js/jquery1.6.2.js"></script>
	<script type="text/javascript" src="../external/jquery.bgiframe-2.1.2.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.core.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.widget.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.mouse.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.button.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.draggable.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.position.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.resizable.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.dialog.js"></script> 
	<script type="text/javascript" src="../js/jquery.effects.core.js"></script> 
	<script type="text/javascript" src="../js/jquery.ajax.upfile.js"></script>
	<script  type="text/javascript" src="../js/jquery.ui.datepicker.js"></script>
	<script type="text/javascript" src="../js/jquery.ingrid.js"></script>
	<link rel="Stylesheet" href="../css/ingrid.css" />
    <link rel="stylesheet" href="../css/demos.css" />
    <link rel="stylesheet" href="../css/jquery.ui.all.css" />
    <script type="text/javascript">
    $(function(){
    $("#dialog-form").dialog("destory");
          var expiretime = $( "#expiretime" ),
				    num=$("#num"),
				    allFields = $( [] ).add( expiretime ).add(num),
				    tips = $( ".validateTips" );
                function updateTips(t)
                {
                  tips.text(t)	
                      .addClass("ui-state-highlight");
                  setTimeout(function(){
                      tips.removeClass("ui-state-highlight",1500);
                  },500);
                }
                function checkEmpty(e,n)
                {
                  if(e.val().length>0){
                     return true;}
                  else{
                     e.addClass("ui-state-error");
                     updateTips(n+"不能为空.");
                     return false;
                     }
                }
                function NewCardAdd()
                {
                  var i=$("#cardname").find("option:selected").attr("value"),n=$("#num").val(),e=$("#expiretime").val();
                  $.ajax({
                        async:false,
                        url:'../API/A_Card.aspx',
                        type:'POST',
                        data:{edit:'create',i:i,n:n,e:e},
                        success:function(msg)
                        {
                           alert(msg);
                        }
                  });
                }
                $("#expiretime").datepicker({
                       disabled:true,
                       changeYear:false,
                       changeMonth:false,
                       dateFormat:'yy-mm-dd',
                       monthNames:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
                       dayNamesMin:["日","一","二","三","四","五","六"],
                       altField:'#expiretime',
                 });
                $("#dialog-form").dialog({
                     autoOpen:false,
                     height:300,
                     width:600,
                     modal:true,
                     buttons:{
                               "提交":function(){
                                   var flag=true;
                                   allFields.removeClass("ui-state-error");
                                   flag=flag && checkEmpty(num,"生成数量");

                                   if(flag)
                                   {
                                        NewCardAdd()
                                        $(this).dialog("close");
                                        
                                   }
                               },
                               "取消":function(){
                                   $(this).dialog("close");
                               },
                             },
                      close:function(){allFields.val("").removeClass("ui-state-error");
                      },
          });
          function GetDeputyList()
          {
            $.ajax({
                 async:false,
                 url:'../API/A_Card.aspx',
                 type:'POST',
                 data:{edit:'deputylist'},
                 success:function(msg)
                 {
                   $("#cardname").append(msg);
                   $("#cardnamelist").append(msg);
                 }
            });
          }
          
          function GetCardList()
          {
          var i=$("#cardnamelist").find("option:selected").attr("value");
            $.ajax({
               async:false,
               url:'../API/A_Card.aspx',
               type:'POST',
               data:{edit:'cardlist',i:i},
               success:function(msg)
               {
                 $("#cardlist tbody").text("");
                 $("#cardlist tbody").append(msg);
                 
               }
            })
            
          }
          function SetTable(){
		  $("#cardlist").tableSorter({
		        sortColumn: 'name',			
		        sortClassAsc: 'headerSortUp',		
		        sortClassDesc: 'headerSortDown',	
		        headerClass: 'header',
		  });}
		  
          $("#create-user").button().click(function(){$("#dialog-form").dialog("open");});
          $("#select").click(function(){GetCardList();});
          $(document).ready(function(){
                GetDeputyList();SetTable();
          })
    })
    </script>
    <style type="text/css">
        body { font-size: 62.5%; }
		label, input { display:block;}
		input.text { margin-bottom:12px; width:95%; padding: .4em; }
		fieldset { padding:0; border:0; margin-top:25px; }
		h1 { font-size: 1.2em; margin: .6em 0; }
		div#users-contain { width: 350px; margin: 20px 0; }
		div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
		div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
		.ui-dialog .ui-state-error { padding: .3em; }
    	.validateTips { border:1px transparent solid; padding: 0.3em; }
		.validateTips input{border:1}
		.text{border:1}
		div#img-size{ width:200px}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    生成新手卡
    <a id="create-user">生成新手卡</a>
    <br />
    <select id="cardnamelist">
    </select><input type="button" value="查询" id="select" />
    <table id="cardlist">
      <thead>
        <tr>
          <th>总数</th>
          <th>剩余数量</th>
          <th>使用数量</th>
          <th>过期数量</th>
          <th>领取数量</th>
        </tr>
      </thead>
      <tbody>
      
      </tbody>
      <tfoot>
      
      </tfoot>
    </table>
    <div id="dialog-form" title="添加新手卡">
    <p class="validateTips">填写要生成新手卡的信息.</p> 
    <fieldset>
      <label for="cardname">新手卡名称</label>
       <select id="cardname">
       
       </select>
       <label for="expiretime">到期时间</label>
       <input type="text" id="expiretime" name="expiretime" class="text ui-widget-content ui-corner-all" />
       <label for="num">生成数量</label>
       <input type="text" id="num" name="num" class="text ui-widget-content ui-corner-all" />
    </fieldset>
    </div>
    </div>
    </form>
</body>
</html>
